#ifndef __WAVEOUT_H__
#define __WAVEOUT_H__

#include <windows.h>
#include <stdio.h>
#include <memory.h>

#define BUFFER_SIZE  1024
#define BUFFER_COUNT 16

typedef struct
{
	WAVEHDR*		waveBlocks;		// pointer to our ring buffer memory
	HWAVEOUT		hWaveOut;		// handle to the waveout device
	unsigned int	buf_write;
	unsigned int	buf_write_pos;
	int				full_buffers;
	int				buffered_bytes;
	unsigned int	buffer_size;
} CWaveOut;

void CWaveOut_Init(CWaveOut* wo);
void CWaveOut_Done(CWaveOut* wo);

int CWaveOut_Open(CWaveOut* wo, int sample_rate, int channels);
int CWaveOut_PushSample(CWaveOut* wo, short sample);
int CWaveOut_Write(CWaveOut* wo, const short* pcm, int size);
int CWaveOut_WriteNotWait(CWaveOut* wo, const short* pcm, int size);
int CWaveOut_Drain(CWaveOut* wo);
int CWaveOut_Close(CWaveOut* wo);

void CWaveOut_Pause(CWaveOut* wo);
void CWaveOut_Resume(CWaveOut* wo);

#endif // __WAVEOUT_H__
